package com.xiaoqi.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.xiaoqi.constant.MessageConstant;
import com.xiaoqi.pojo.Result;
import com.xiaoqi.pojo.Setmeal;
import com.xiaoqi.service.SetmealMobileService;
import com.xiaoqi.utils.QiNiuUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author PC
 * creationTime: 2022/11/12 10:24
 */

@RequestMapping("/setmealmobile")
@RestController
public class SetmealMobileController {

    @Reference
    private SetmealMobileService setmealMobileService;


    /**
     * 查询所有套餐
     * @return
     */
    @GetMapping("/findAll")
    public Result findAll(){
        List<Setmeal> list = setmealMobileService.findAll();
        for (Setmeal setmeal : list) {
            setmeal.setImg(QiNiuUtils.DOMAIN+setmeal.getImg());
        }
        return new Result(true, MessageConstant.QUERY_SETMEAL_SUCCESS,list);
    }

    /**
     * 更具套餐id查询套餐详情包括检查组与检查项
     * @param id
     * @return
     */
    @GetMapping("/findDetailById")
    public Result findDetailById(Integer id){
        Setmeal setmeal = setmealMobileService.findDetailById(id);
        setmeal.setImg(QiNiuUtils.DOMAIN+setmeal.getImg());
        return new Result(true,MessageConstant.QUERY_SETMEAL_SUCCESS,setmeal);
    }

    /**
     * 通过id查询套餐
     * @param id
     * @return
     */
    @GetMapping("/findById")
    public Result findById(Integer id){
        Setmeal setmeal = setmealMobileService.findById(id);
        setmeal.setImg(QiNiuUtils.DOMAIN+setmeal.getImg());
        return new Result(true,MessageConstant.QUERY_SETMEAL_SUCCESS,setmeal);
    }


}
